//package com.dykj.fireFighting.web.mq.consumer.business;
//
//import com.alibaba.fastjson.JSON;
//import com.dykj.fireFighting.common.core.constant.WebsocketConstant;
//import com.dykj.fireFighting.common.starter.redisson.service.RedisService;
//import com.dykj.fireFighting.web.base.websocket.entity.MoreMessage;
//import com.dykj.fireFighting.web.model.Device;
//import com.dykj.fireFighting.web.model.vo.MqMessage;
//import com.dykj.fireFighting.web.utils.SpringUtil;
//import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
//import org.apache.rocketmq.common.message.Message;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.io.UnsupportedEncodingException;
//
//
///**
// * @Author fgc
// * @Date 2021/9/30 10:12
// * @ Description：MQ消息业务处理--设备运行记录入库
// */
//public class WaterWebSocketPush extends BusinessProcess{
//    public static final Logger LOGGER = LoggerFactory.getLogger(WaterWebSocketPush.class);
//    private static RedisService redisService=(RedisService) SpringUtil.getBean(RedisService.class);
//    public WaterWebSocketPush(){
//        super();
//    }
//    @Override
//    public ConsumeConcurrentlyStatus process(Message msg){
//        LOGGER.info("进入websocket推送业务实现");
//        String msgBody= null;
//        try {
//            msgBody = new String (msg.getBody(),"utf-8");
//            MqMessage mqMessage = JSON.parseObject(msgBody, MqMessage.class);
//            Device device = mqMessage.getDevice();
//            String time = mqMessage.getAlarmTime().substring(11);
//            MoreMessage moreMessage=new MoreMessage();
//            moreMessage.setMsgId(mqMessage.getDevHisId());
//            switch (device.getStatus()){
//                case "液位低限预警":
//                    moreMessage.setMsgTitle("液位低限预警通知");
//                    moreMessage.setCmd(WebsocketConstant.CMD_TOPIC);
//                    moreMessage.setMsgTxt(device.getName()+"设备于今天"+time+"上报液位为："+device.getCalculationValue()+",低于标定量程："+device.getThresholdL()+";设备发出报警，请及时处理");
//                    moreMessage.setUserIds(mqMessage.getUnit().getUnitUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    moreMessage.setMsgTxt(mqMessage.getUnit().getUnitName()+"的"+device.getName()+"设备于今天"+time+"上报液位为："+device.getCalculationValue()+",低于标定量程："+device.getThresholdL()+";设备发出报警，请及时处理");
//                    moreMessage.setUserIds(mqMessage.getUnit().getCenterUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    break;
//                case "压力低限预警":
//                    moreMessage.setMsgTitle("压力低限预警通知");
//                    moreMessage.setCmd(WebsocketConstant.CMD_TOPIC);
//                    moreMessage.setMsgTxt(device.getName()+"设备于今天"+time+"上报压力为："+device.getCalculationValue()+",低于标定量程："+device.getThresholdL()+";设备发出报警，请及时处理");
//                    moreMessage.setUserIds(mqMessage.getUnit().getUnitUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    moreMessage.setMsgTxt(mqMessage.getUnit().getUnitName()+"的"+device.getName()+"设备于今天"+time+"上报压力位为："+device.getCalculationValue()+",低于标定量程："+device.getThresholdL()+";设备发出报警，请及时处理");
//                    moreMessage.setUserIds(mqMessage.getUnit().getCenterUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    break;
//                case "液位高限报警":
//                    moreMessage.setMsgTitle("液位高限预警通知");
//                    moreMessage.setCmd(WebsocketConstant.CMD_TOPIC);
//                    moreMessage.setMsgTxt(device.getName()+"设备于今天"+time+"上报液位为："+device.getCalculationValue()+",高于标定量程："+device.getThresholdH()+";设备发出报警，请及时处理");
//                    moreMessage.setUserIds(mqMessage.getUnit().getUnitUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    moreMessage.setMsgTxt(mqMessage.getUnit().getUnitName()+"的"+device.getName()+"设备于今天"+time+"上报液位为："+device.getCalculationValue()+",高于标定量程："+device.getThresholdH()+";设备发出报警，请及时处理");
//                    moreMessage.setUserIds(mqMessage.getUnit().getCenterUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    break;
//                case "压力高限报警":
//                    moreMessage.setMsgTitle("压力高限预警通知");
//                    moreMessage.setCmd(WebsocketConstant.CMD_TOPIC);
//                    moreMessage.setMsgTxt(device.getName()+"设备于今天"+time+"上报压力为："+device.getCalculationValue()+",高于标定量程："+device.getThresholdH()+";设备发出报警，请及时处理");
//                    moreMessage.setUserIds(mqMessage.getUnit().getUnitUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    moreMessage.setMsgTxt(mqMessage.getUnit().getUnitName()+"的"+device.getName()+"设备于今天"+time+"上报压力位为："+device.getCalculationValue()+",高于标定量程："+device.getThresholdH()+";设备发出报警，请及时处理");
//                    moreMessage.setUserIds(mqMessage.getUnit().getCenterUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    break;
//                case "液位恢复":
//                    moreMessage.setMsgTitle("液位恢复通知");
//                    moreMessage.setCmd(WebsocketConstant.CMD_TOPIC);
//                    moreMessage.setMsgTxt(device.getName()+"设备于今天"+time+"液位已恢复;当前液位为："+device.getCalculationValue());
//                    moreMessage.setUserIds(mqMessage.getUnit().getUnitUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    moreMessage.setMsgTxt(mqMessage.getUnit().getUnitName()+"的"+device.getName()+"设备于今天"+time+"液位已恢复;当前液位为："+device.getCalculationValue());
//                    moreMessage.setUserIds(mqMessage.getUnit().getCenterUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    break;
//                case "压力恢复":
//                    moreMessage.setMsgTitle("压力恢复通知");
//                    moreMessage.setCmd(WebsocketConstant.CMD_TOPIC);
//                    moreMessage.setMsgTxt(device.getName()+"设备于今天"+time+"压力已恢复;当前液位为："+device.getCalculationValue());
//                    moreMessage.setUserIds(mqMessage.getUnit().getUnitUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    moreMessage.setMsgTxt(mqMessage.getUnit().getUnitName()+"的"+device.getName()+"设备于今天"+time+"压力已恢复;当前液位为："+device.getCalculationValue());
//                    moreMessage.setUserIds(mqMessage.getUnit().getCenterUserIds().toArray(new String[0]));
//                    redisService.convertAndSend("channel:moreMessage",moreMessage);
//                    break;
//            }
//            return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
//        } catch (UnsupportedEncodingException e) {
//            e.printStackTrace();
//            return ConsumeConcurrentlyStatus.RECONSUME_LATER;
//        }
//
//    }
//
//}
